<template>
  <div>
    <div ref="chart" class="chart" />

  </div>
</template>
<script>
import * as echarts from 'echarts'
import { dataStatistics } from '@/api/test'
export default {
  data() {
    return {
      list: []
    }
  },

  async created() {
    await this.getData()
    const myCharts = echarts.init(this.$refs.chart)
    const option = {
      title: {
        text: 'Referer of a Website',
        subtext: 'Fake Data',
        left: 'center'
      },
      tooltip: {
        trigger: 'item'
      },
      legend: {
        orient: 'vertical',
        left: 'left'
      },
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: '50%',
          data: this.list,
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        }
      ]
    }
    myCharts.setOption(option)
  },

  methods: {
    async getData() {
      const res = await dataStatistics()
      this.list = res.data.data
      console.log(res)
    }
  }
}
</script>
<style>
.chart{
    height:500px;
}
</style>
